10_Q_Learning
Tags: #◇CSINTSY #◇Computational Thinking #◇Computer Science #◇Artificial Intelligence #◇Machine Learning #◇Intelligent Systems #◇Probability #◇Data Analysis
◇Overview
Q-Learning is a model-free reinforcement learning algorithm.
◇Details / Theory
10. Q-Learning Reviewer
◇Overview
Q-Learning is a model-free reinforcement learning algorithm.
Model-Free: It does not need to know the Transition Probability () or Reward Function () of the environment beforehand. It learns by trial and error. Goal: To learn the Q-Function (Quality Function), which estimates the value of taking a specific action in a specific state.
◇The Q-Function:
Represents the expected cumulative future reward of taking action in state , and then acting optimally afterwards. Once we know for all states and actions, the optimal policy is simply to pick the action with the highest Q-value in each state:
◇The Q-Table
A table (matrix) where rows are States and columns are Actions. Each cell contains the value . Initialized to 0 (or random values). Updated iteratively as the agent interacts with the environment.
◇Q-Learning Update Rule (Bellman Update)
When the agent is in state , takes action , receives reward , and lands in new state , we update the Q-value:
Components:
- : The current estimated value (Old Value).
- (Alpha): Learning Rate ().
Determines how much new information overrides old information.
High : Learn fast, but volatile.
Low : Learn slow, but stable. - : Immediate reward received.
- (Gamma): Discount Factor (). Importance of future rewards.
- : The estimate of optimal future value from the next state . We assume we will take the best action from there.
- Temporal Difference (TD) Error: The term in the brackets . It represents the difference between what we expected and what actually happened.
◇Exploration vs. Exploitation
How does the agent choose actions while learning?
Exploration: Trying new or random actions to discover their rewards. Necessary to find better paths. Exploitation: Choosing the action currently known to be the best (highest Q-value) to maximize reward.
Epsilon-Greedy Strategy (-greedy)
A common method to balance exploration and exploitation.
With probability (epsilon): Explore (choose a random action). With probability : Exploit (choose the best action from Q-table). Usually, starts high (explore a lot) and decays over time (exploit more as we learn).
◇Solved Example: Q-Value Update
Scenario:
Current State (): Room A. Action (): Move to Room B. Reward (): +10 (Found a coin). Next State (): Room B. Current Q-Value : 5. Best Q-Value in Next State : 20 (Maybe Room B is close to exit). Learning Rate (): 0.1. Discount Factor (): 0.9.
Calculation:
-
Target Value:
-
Difference (TD Error):
-
New Q-Value:
Result: The Q-value for moving from A to B increased from 5 to 7.3 because the outcome was better than expected.
◇Common Pitfalls
Confusing the learning rate (how much to update) with the discount factor (how much to value future rewards). Forgetting that Q-Learning is model-free — it does not need transition probabilities; it learns from experience. Using pure exploitation () too early — sufficient exploration is needed for the Q-table to converge.
◇Summary
TL;DR — Q-Learning updates Q-values via . It’s model-free, uses -greedy for exploration/exploitation balance, and converges to optimal Q-values with sufficient exploration.
◇Links
Related: Source / Reference:
Made by 2ru17
Please contact me through discord or my the university email for any problems regarding the reviewer. Thanks!
◇References & Navigation
- Previous Topic: ◇MDP
- Related Notes: ◇Q-Learning
ACTIVE RECALL VERIFICATION
Select an answer to verify conceptual comprehension and reveal the technical rationale.
What does it mean for Q-Learning to be a "model-free" algorithm?
In Q-Learning, what does the Q-Function represent?
How are the values in a Q-Table typically initialized before the agent starts learning?
What is the role of the Learning Rate () in the Q-Learning update rule?
In the Q-Learning update rule, what does the term represent?
What does the Temporal Difference (TD) Error represent?
In the context of reinforcement learning, what is "Exploration"?
What is the purpose of the Epsilon-Greedy (-greedy) strategy?
How does the parameter (epsilon) typically change over time in a Q-Learning implementation?
What happens if an agent uses pure exploitation () too early in the learning process?